package com.domain.service.impl;

import com.domain.common.Result;
import com.domain.dao.UsersWalletMapper;
import com.domain.pojo.UsersWallet;
import com.domain.service.UsersWalletService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class UsersWalletServiceImpl implements UsersWalletService {
    @Autowired
    private UsersWalletMapper usersWalletMapper;

    /**
     * 我的钱包
     *
     * @param userId
     * @return
     */
    @Override
    public Result getUsersWallet(String userId) {

        UsersWallet usersWa = usersWalletMapper.selectByUserId(userId);
        return Result.success("操作成功", usersWa);
    }

    /**
     * 绑定支付宝账号
     *
     * @param usersWalleId
     * @param alipayNum
     * @return
     */
    @Override
    public Result bindAlipay(String usersWalleId, String alipayNum) {
        UsersWallet usersWallet = usersWalletMapper.selectByPrimaryKey(usersWalleId);
        usersWallet.setAlipayNumber(alipayNum);
        usersWallet.setUpdateTime(new Date());
        usersWalletMapper.updateByPrimaryKeySelective(usersWallet);
        return Result.success("操作成功");
    }
}
